<template>
  <div class="app-container">
    <div class="filter-container">
      <!--返回上一步-->
      <div class="back-bar-box mb-30">
        <div class="btn-back" @click="$router.go(-1)"><i class="el-icon-back"></i> 返回</div>
        <div class="line"></div>
        <div class="name">{{$route.name}}</div>
      </div>
      <!--查询表单-->
      <el-form :inline="true" class="demo-form-inline  mb-20">
        <el-button type="primary" icon="el-icon-circle-plus-outline" size="small" @click="goEdit()"
                   v-permission="'path:add'">添加
        </el-button>
      </el-form>
    </div>
    <el-table :data="list" v-loading="listLoading" border fit
              highlight-current-row>
      <el-table-column align="center" prop="sort" label="排序" width="80">
      </el-table-column>

      <el-table-column align="center" prop="name" label="步骤名"></el-table-column>
      <el-table-column align="center" prop="description" label="描述"></el-table-column>

      <el-table-column align="center" label="管理" width="200">
        <template slot-scope="scope">
          <el-link type="primary" @click="goCourse(scope.row.id)" v-permission="'path:update'">课程</el-link>
          <el-link type="primary" @click="goEdit(scope.row.id)" v-permission="'path:update'">编辑</el-link>
          <el-link type="danger" @click="removeDataById(scope.row.id)" v-permission="'path:delete'">删除</el-link>

        </template>
      </el-table-column>
    </el-table>
    <!-- 分页 -->
    <el-pagination
      :current-page="page"
      :page-size="limit"
      :total="total"
      background
      style="padding: 30px 0; text-align: center;"
      layout="total, prev, pager, next, jumper"
      @current-change="getList"
    />
  </div>
</template>

<script>
  export default {
    data() {
      return {
        dataQuery: {},
        list: [],//表格的数据
        listLoading: false,//数据加载等待动画
        page: 1, //当前页
        limit: 5, //每页记录数
        total: 0, //总记录数
      }
    }, created() {
      this.getList()
    }, methods: {
      getList() {
        this.api({
          url: `/step/pageListStepCondition/${this.page}/${this.limit}`,
          method: 'post',
        }).then(data => {
          //删除视频后重置id
          this.list = data.list;
          this.total = data.totalCount;
        })
      },
      goCourse(id) {
        this.$router.push("/learningpath/step/relation/"+id)
      },
      goEdit(id) {
        let s = id ? '/' + id : '?pid='+this.$route.params.id;
        this.$router.push("/learningpath/stepedit" + s)
      },
      removeDataById(id) {

      }
    }
  }
</script>
